package com.atguigu.blog.aop;

import com.atguigu.blog.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//定义全局异常处理机制
@RestControllerAdvice
public class ResultAOP {

    //引入日志
    private static final Logger LOGGER = LoggerFactory.getLogger(ResultAOP.class);

    @ExceptionHandler(RuntimeException.class)
    public Result fail(Exception e){
        LOGGER.error(e.getMessage());
        return Result.fail();
    }
}
